var wmAnchor = {
	data: {
		nav: null,
		navPage: null,
		topArr: []
	},
	init: function() {
		var that = this;
		that.data.nav = $('.wm-anchor-nav');
		that.data.navPage = $('.wm-anchor-navMain .wm-anchor-navPage');

		$.each(that.data.navPage, function(index, obj) {
			var _top = $(obj).offset().top;
			that.data.topArr.push(_top);
		});

		$(window).off('scroll').on('scroll', function() {
			var _scrollTop = $(this).scrollTop();
			var _index = 0;

			$.each(that.data.topArr, function(index, obj) {
				if (_scrollTop >= obj) {
					_index = index;
				}
			});

			that.data.nav.find("a").eq(_index).addClass('active').siblings().removeClass('active');
		});

		that.data.nav.find("a[href^='#']").off().on('click', function(e) {
			e.preventDefault();
			$('html, body').animate({
				scrollTop: $(this.hash).offset().top
			}, 400);
			$('html, body').offset().top = 0;
		});
	}
}
